try!(walk(path, &mut |dir| {
trace!("looking for child package: {}", dir.display());
- // Don't recurse into git databases
- if dir.file_name().and_then(|s| s.to_str()) == Some(".git") {
+ // Don't recurse into hidden/dot directories
+ let name = dir.file_name().and_then(|s| s.to_str());
+ if name.map(|s| s.starts_with(".")) == Some(true) {
return Ok(false)
}
}
for dir in try!(fs::read_dir(path)) {
let dir = try!(dir).path();
- match (is_root, dir.file_name().and_then(|s| s.to_str())) {
- (_, Some(".git")) |
- (true, Some("target")) |
- (true, Some("Cargo.lock")) => continue,
- _ => {}
+ let name = dir.file_name().and_then(|s| s.to_str());
+ // Skip dotfile directories
+ if name.map(|s| s.starts_with(".")) == Some(true) {
+ continue
+ } else if is_root {
+ // Skip cargo artifacts
+ match name {
+ Some("target") | Some("Cargo.lock") => continue,
+ _ => {}
+ }
}
try!(PathSource::walk(&dir, ret, false, filter));
}
execs().with_status(0));
});
+test!(ignore_dotdirs {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("src/bin/a.rs", "fn main() {}")
+ .file(".git/Cargo.toml", "")
+ .file(".pc/dummy-fix.patch/Cargo.toml", "");
+ p.build();
+
+ assert_that(p.cargo("build"),
+ execs().with_status(0));
+});
+
+
test!(custom_target_dir {
let p = project("foo")
.file("Cargo.toml", r#"